package scjp.preparation.local;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Locale.Category;

public class CustomDatePatterns {

	public static void main(String[] args) {
		// patterns from simple to complex ones
		String[] dateFormats = { "dd-MM-yyyy", /*
												 * d is day (in month), M is
												 * month, y is year
												 */
		"d '('E')' MMM, YYYY", /* E is name of the day (in week), Y is year */
		"w'th week of' YYYY", /* w is the week of the year */
		"EEEE, dd'th' MMMM, YYYY" /* E is day name in the week */
		};
		Date today = new Date();
		System.out.println("Default format for the date is "
				+ DateFormat.getDateInstance().format(today));
		for (String dateFormat : dateFormats) {
			System.out.printf("Date in pattern \"%s\" is %s %n", dateFormat,
					new SimpleDateFormat(dateFormat).format(today));
		}
		
		Locale l1 = new Locale.Builder().setLanguage("en").setRegion("US").build();
		Locale l2 = Locale.forLanguageTag("en-US");
		Locale.setDefault(Category.DISPLAY,Locale.JAPAN);
		Locale l3 = Locale.getDefault();
		System.out.println(l3);
	}

}
